package com.cljz.peipei.utils;

/**星座
 * Created by CLJZ on 2017/5/23.
 */

public class ConstellationUtils {
    private static String[] constellations = {"白羊座", "金牛座", "双子座", "巨蟹座", "狮子座", "处女座", "天秤座", "天蝎座", "射手座", "摩羯座", "水瓶座", "双鱼座"};
    private static String[] couple={"狮子座","魔羯座","水瓶座","双鱼座","白羊座","射手座","水瓶座","双鱼座","射手座","处女座","双子座","天蝎座"};
    public static String getConstellation(int i){
        if (i < 13 && i > 0){
            return constellations[i-1];
        }else {
            return "";
        }
    }

    public static String getCouple(int i) {
        if (i < 13 && i > 0){
            return couple[i-1];
        }else {
            return "";
        }
    }

    public static String getStr(String constellation){
        for (int i = 0; i < constellations.length -1; i++) {
            if (constellations[i].equals(constellation)){
                return (i+1)+"";
            }
        }
        return -1+"";
    }

    /**
     * 根据传入的时间，返回星座
     * @param date 时间字符串 格式：yyyy-MM-dd
     * @return 星座
     */
    public static String getConstellation(String date){
        String[] split = date.split("-");
        int month = Integer.parseInt(split[1]);
        int day = Integer.parseInt(split[2]);
        String star = "";

        if (month == 1 && day >= 20 || month == 2 && day <= 18) {
            star = "水瓶座";
        }
        if (month == 2 && day >= 19 || month == 3 && day <= 20) {
            star = "双鱼座";
        }
        if (month == 3 && day >= 21 || month == 4 && day <= 19) {
            star = "白羊座";
        }
        if (month == 4 && day >= 20 || month == 5 && day <= 20) {
            star = "金牛座";
        }
        if (month == 5 && day >= 21 || month == 6 && day <= 21) {
            star = "双子座";
        }
        if (month == 6 && day >= 22 || month == 7 && day <= 22) {
            star = "巨蟹座";
        }
        if (month == 7 && day >= 23 || month == 8 && day <= 22) {
            star = "狮子座";
        }
        if (month == 8 && day >= 23 || month == 9 && day <= 22) {
            star = "处女座";
        }
        if (month == 9 && day >= 23 || month == 10 && day <= 22) {
            star = "天秤座";
        }
        if (month == 10 && day >= 23 || month == 11 && day <= 21) {
            star = "天蝎座";
        }
        if (month == 11 && day >= 22 || month == 12 && day <= 21) {
            star = "射手座";
        }
        if (month == 12 && day >= 22 || month == 1 && day <= 19) {
            star = "摩羯座";
        }

        return star;
    }
}
